package com.work.vo.main;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.work.constant.DictBizConstant;
import com.work.utils.BigDecimalSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.cache.DictBizCache;

import java.math.BigDecimal;
import java.time.LocalDate;

/**
 * 多垛理货解锁VO
 *
 * @author ：dujianyu
 * @since ：Created in 2024/6/18 9:54
 */
@Data
public class TwoStockTallyUnlockVO {

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "id")
    private Long id;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "id")
    private Long oriTransportBillId;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "id")
    private Long oriTransportShipId;

    @ApiModelProperty(value = "理货日期")
    private LocalDate tallyDate;

    @ApiModelProperty(value = "时间段")
    private String timeSpace;

    @ApiModelProperty(value = "时间段")
    private String timeSpaceName;

    public String getTimeSpaceName() {
        if (Func.isNull(timeSpace)) {
            return "";
        }
        return DictBizCache.getValue(DictBizConstant.TIME_SPACE, timeSpace);
    }

    @ApiModelProperty(value = "时间信息")
    private String timeInfo;

    public String getTimeInfo() {
        if (Func.isNull(timeSpace) || Func.isNull(tallyDate)) {
            return "";
        }
        return tallyDate + "/" + DictBizCache.getValue(DictBizConstant.TIME_SPACE, timeSpace);
    }

    @ApiModelProperty(value = "船名")
    private String oriShipNameZh;

    @ApiModelProperty(value = "航次")
    private String oriVoyage;

    @ApiModelProperty(value = "船信息")
    private String oriShipInfo;

    public String getOriShipInfo() {
        if (Func.isNull(oriShipNameZh) || Func.isNull(oriVoyage)) {
            return "";
        }
        return oriShipNameZh + "/" + oriVoyage;
    }

    @ApiModelProperty(value = "舱单号")
    private String oriBillNo;

    @ApiModelProperty(value = "舱单货名")
    private String oriBillCargoType;

    @ApiModelProperty(value = "舱单货名")
    private String oriBillCargoTypeName;

    @ApiModelProperty(value = "理货包装")
    private String tallyPackageType;

    @ApiModelProperty(value = "理货包装")
    private String tallyPackageTypeName;

    @ApiModelProperty(value = "理货类型")
    private String tallyType;

    @ApiModelProperty(value = "理货类型")
    private String tallyTypeName;

    public String getTallyTypeName() {
        if (Func.isNull(tallyType)) {
            return "";
        }
        return DictBizCache.getValue(DictBizConstant.TALLY_TYPE, tallyType);
    }

    @ApiModelProperty(value = "作业过程")
    private String operationType;

    @ApiModelProperty(value = "作业过程")
    private String operationTypeName;

    @ApiModelProperty(value = "航陆运")
    private String shipLand;

    @ApiModelProperty(value = "航陆运")
    private String shipLandName;

    public String getShipLandName() {
        if (Func.isNull(shipLand)) {
            return "";
        }
        return DictBizCache.getValue(DictBizConstant.SHIP_LAND, shipLand);
    }

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "区域ID")
    private Long areaId;

    @ApiModelProperty(value = "是否审核")
    private String isCheck;

    public String getIsCheck() {
        if (Func.isNull(isCheck)) {
            return "OT";
        }
        return isCheck;
    }

    @ApiModelProperty(value = "是否审核")
    private String isEdit;

    @ApiModelProperty(value = "理货员")
    private String createUserName;

    @ApiModelProperty(value = "安全生产")
    private String isSafeProduction;

    @ApiModelProperty(value = "作业前件数")
    private Integer oriPiece;

    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(value = "作业前吨数")
    private BigDecimal oriTon;

    @ApiModelProperty(value = "作业后件数")
    private Integer toPiece;

    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(value = "作业后吨数")
    private BigDecimal toTon;

    @ApiModelProperty(value = "件信息")
    private String pieceInfo;

    public String getPieceInfo() {
        if (Func.isNull(oriPiece) || Func.isNull(toPiece)) {
            return "";
        }
        return oriPiece + "->" + toPiece;
    }

    @ApiModelProperty(value = "吨信息")
    private String tonInfo;

    public String getTonInfo() {
        if (Func.isNull(oriTon) || Func.isNull(toTon)) {
            return "";
        }
        return oriTon.stripTrailingZeros() + "->" + toTon.stripTrailingZeros();
    }
}
